//#ifndef __tenacitas_time__patterns__h__
//#define __tenacitas_time__patterns__h__


//// -----------------------------------------------------------------------------
////                                   C++ headers
//// -----------------------------------------------------------------------------
//#include <list>

//// -----------------------------------------------------------------------------
////                                   3rds headers
//// -----------------------------------------------------------------------------
//#include <algorithm>

//// -----------------------------------------------------------------------------
////                                   our headers
//// -----------------------------------------------------------------------------
//#include "date.h"
//#include "algorithm.h"
//#include "criteria.h"

//// -----------------------------------------------------------------------------
////                                   namespaces
//// -----------------------------------------------------------------------------
//using namespace std;
//using namespace tenacitas;

//// -----------------------------------------------------------------------------
////                                   macro constants
//// -----------------------------------------------------------------------------


///**  */

//// -----------------------------------------------------------------------------
////                                   macro commands
//// -----------------------------------------------------------------------------

///**  */

//// -----------------------------------------------------------------------------
////                                   typedefs
//// -----------------------------------------------------------------------------


///**  */


///** namespace of the organization  */
//namespace tenacitas {

//    // ---------------------------------------------------------------------
//    //                           pre-declarations
//    // ---------------------------------------------------------------------


//    // ---------------------------------------------------------------------
//    //                          typedefs
//    // ---------------------------------------------------------------------

     
//    /**  */

//    // ---------------------------------------------------------------------
//    //                          declarations
//    // ---------------------------------------------------------------------

//    /** This class determines a valid next time, based on a previous
//     * time
//     *
//     * @note The t_time should conform to the tenacitas::date
//     * class, i.e, it must implement equivalent types and methods.
//     *
//     * It uses a collection of t_time_type::day_value objects to determine
//     * the next valid time.
//     *
//     * If an invalid time is calculated, say 2009.02.29 or 2009.04.31, this
//     * time is not considered.
//     *
//     * For example, supposing t_time is tenacitas::date, and if
//     * the valid days are 4, 17, 21, the next valid tenacitas::date
//     * after 2009.02.10 is 2009.02.17.  */
//    template <typename t_time>
//    class monthly_by_day :
//	public recurrence_criteria<t_time, typename t_time::month_type> {

//    public:

//	// -----------------------------------------------------------------
//	// recurrence  public internal types
//	// -----------------------------------------------------------------

//	/** Type for the type of day  */
//	typedef typename t_time::day_type day_type;

//	typedef t_time time_type;

//	typedef typename t_time::month_type period_type;
	
//	typedef typename
//	tenacitas::recurrence_criteria<time_type, period_type>
//	criteria_type;
	

//	// -----------------------------------------------------------------
//	// monthly_by_day  public constructor
//	// -----------------------------------------------------------------

//	monthly_by_day ( const typename criteria_type::creation_policy &
//			 p_on_holidays,
			   
//			 const typename criteria_type::creation_policy &
//			 p_on_weekends,
			   
//			 const typename criteria_type::creation_policy &
//			 p_on_exceptions,
			   
//			 const typename criteria_type::creation_policy &
//			 p_on_invalid_times,

//			 const list<typename t_time::date_type> & p_holidays ) :
		
//	    criteria_type ( p_on_holidays,
//			    p_on_weekends,
//			    p_on_exceptions,
//			    p_on_invalid_times,
//			    p_holidays) {}
	    
	    
//	// -----------------------------------------------------------------
//	// monthly_by_day  public processor
//	// -----------------------------------------------------------------

//	/** @copydoc tenacitas::recurrence_criteria  */
//	t_time first_time ( const t_time & p_time ) const {

//	    /* the first time_type is the first time_type::day_type in the list
//             * of time_type::day_type objects that are valid, according to this
//             * criteria, combined with the month and year of the informed
//             * time_type
//             * this "combination" is made in such a way that it is guaranteed
//             * that the calculated time_type is valid
//             */
//	    day_type aux = round_day ( *m_days.begin ( ) ,
//				       p_time.get_month( ) ,
//				       p_time.get_year ( ) ) ;
		
//	    t_time rc ( aux, p_time.get_month( ) , p_time.get_year ( ) ) ;

//	    return rc;
//	}
	    
//	/** @copydoc tenacitas::recurrence_criteria  */
//	bool next ( const t_time & p_previous,
//		    t_time & p_time ) const throw ( fault ) {

//	    bool rc = false;

//	    // we look for the next from the previous... 8)
//	    p_time = p_previous;
		
//	    // for all the t_time::day_type in the collection
//	    // of valid t_time::day_type...
//	    typename list<typename t_time::day_type>::const_iterator
//		i = m_days.begin ( ) ;

//	    for ( ; i != m_days.end ( ); ++i) {
//		if ( p_previous.get_day ( ) < *i ) {
//		    // we found a day_type in the collection of valid
//		    // day_type objects, which is greater than the previous
//		    // t_time, so, we (try) to just change its
//		    // day_type value to the one of the collection

//		    try {
			
//			p_time.set_day ( *i ) ; // may throw

//			rc = true;
//			break;
//		    }
//		    catch ( fault e ) {
//			// ok, the cadidate day, together with the month and
//			// year produced a invalid time, like 2009.04.31

//			// so, we try to create a valid time
//			rc = handle_invalid_time ( p_previous, *i, p_time );
//		    }
//		}
//	    }
//	    return rc;
//	}

//	/** Adds a new valid @p day_type in the collection
//         * of valid @pday_type objects
//         *
//         * @param [in] d is a @p day_type object we want to use
//         * as a valid one  */
//	void add ( const day_type & p_day ) {
//	    m_days.push_back ( p_day ) ;
//	    m_days.sort ( ) ;
//	}


//	// -----------------------------------------------------------------
//	// monthly_by_day  private attributes
//	// -----------------------------------------------------------------
//	list<typename t_time::day_type> m_days;
	    
	    
//    };

//}


//#endif
